﻿@using Common
@using Web.Helper
@model PagedList<Models.UserModels.ProjectTask>

<div>

    <blockquote class="col-lg-2 pull-left">
        <h3>我的任务 @Ajax.ActionLink("+", "Create", null, new AjaxOptions() { UpdateTargetId = "Main" }, new { @class = "btn" })</h3>
    </blockquote>

    <div class=" col-xs-3  pull-right">
        @Html.Partial("Search_Input")
    </div>

    <div class="col-lg-5 pull-right">
        <ul class="nav nav-pills">
            <li class="@(Request["displaytype"] == null ? "active" : "")">
                @Ajax.ActionLink("全部 " + (int)ViewBag.CountAll, "Index", new { keyword = Request["keyword"] }, new AjaxOptions { UpdateTargetId = "Main" })
            </li>
            <li>&nbsp;</li>
            <li class="@(Request["displaytype"] == "0" ? "active" : "")">
                @Ajax.ActionLink("交给我 " + (int)ViewBag.CountMy, "Index", new { keyword = Request["keyword"], displaytype = "0", finish = Request["finish"] }, new AjaxOptions { UpdateTargetId = "Main" })
            </li>
            <li class="@(Request["displaytype"] == "1" ? "active" : "")">
                @Ajax.ActionLink("我发布 " + (int)ViewBag.CountTo, "Index", new { keyword = Request["keyword"], displaytype = "1", finish = Request["finish"] }, new AjaxOptions { UpdateTargetId = "Main" })
            </li>

            <li>&nbsp;</li>
            <li class="@(Request["finish"] == "False" ? "active" : "")">
                @Ajax.ActionLink("未完成 " + (int)ViewBag.unfinished, "Index", new { keyword = Request["keyword"], displaytype = Request["displaytype"], finish = false }, new AjaxOptions { UpdateTargetId = "Main" })
            </li>
            <li class="@(Request["finish"] == "True" ? "active" : "")">
                @Ajax.ActionLink("已完成 " + (int)ViewBag.finished, "Index", new { keyword = Request["keyword"], displaytype = Request["displaytype"], finish = true }, new AjaxOptions { UpdateTargetId = "Main" })
            </li>
        </ul>
    </div>
   
</div>
<div class="clearfix"></div>
<div>

    @foreach (var item in Model)
    {
        <blockquote>
            <span class="pull-right">
                @*任务发布人*@
                @if (item.UserId.Equals(ViewBag.UserId))
                {
                    //如果项目未处理可以修改删除
                    if (!item.Accept.HasValue)
                    {
                        <a class="btn btn-small btn-info" data-ajax="true" data-ajax-mode="replace" data-ajax-update="#Main" href="@Url.Action("Edit", new { id = item.Id, displaytype = Request["displaytype"], finish = Request["finish"], pageIndex = Request["pageIndex"] })"><i class="fa fa-edit"></i>&nbsp;@lang.Edit</a>

                    }

                    if (!item.Finish)
                    {

                        <span>&nbsp;</span>
                        <a class="btn btn-small btn-danger" data-ajax="true" data-ajax-confirm="您确定要删除该记录吗？该操作不可恢复！" data-ajax-method="Delete" data-ajax-mode="replace" data-ajax-update="#Main" href="@Url.Action("Delete", new {id = item.Id, type = "Delete", displaytype = Request["displaytype"], finish = Request["finish"], pageIndex = Request["pageIndex"]})"><i class="fa fa-times"></i>&nbsp;@lang.Delete</a>
                    }

                    //如果我不是任务负责人可以查看状态
                    if (!item.SysUserId.Equals(ViewBag.UserId) && item.Accept.HasValue)
                    {
                        if (item.Accept.Value)
                        {
                            if (item.Finish)
                            {
                                <span>&nbsp;</span>
                                <a class="btn"><i class="fa fa-check"></i>&nbsp;已完成</a>
                            }
                            else
                            {
                                <span>&nbsp;</span>
                                <a class="btn"><i class="fa fa-check"></i>&nbsp;已接受</a>
                            }
                        }
                        else
                        {
                            <span>&nbsp;</span>
                            <a class="btn"><i class="fa fa-times"></i>&nbsp;已拒绝</a>
                        }
                    }

                }

                @*任务接收人*@
                @if (item.SysUserId.Equals(ViewBag.UserId))
                {
                    if (item.Accept.HasValue)
                    {
                        if (!item.Accept.Value)
                        {
                            <span>&nbsp;</span>
                            <a class="btn btn-small btn-danger" data-ajax="true" data-ajax-confirm="您确定接受该任务吗？" data-ajax-method="Delete" data-ajax-mode="replace" data-ajax-update="#Main" href="@Url.Action("Delete", new { id = item.Id, type = "Accept", finish = Request["finish"], Accept = true, displaytype = Request["displaytype"], pageIndex = Request["pageIndex"] })"><i class="fa fa-times"></i>&nbsp;已拒绝</a>
                        }
                        else
                        {
                            if (item.Finish)
                            {
                                <span>&nbsp;</span>
                                <a class="btn btn-small btn-success" data-ajax="true" data-ajax-confirm="您确定重启该任务吗？" data-ajax-method="Delete" data-ajax-mode="replace" data-ajax-update="#Main" href="@Url.Action("Delete", new { id = item.Id, type = "Finish", finish = false, displaytype = Request["displaytype"], pageIndex = Request["pageIndex"] })"><i class="fa fa-check"></i>&nbsp;已完成</a>
                            }
                            else
                            {
                                <span>&nbsp;</span>
                                <a class="btn btn-small btn-success" data-ajax="true" data-ajax-confirm="您确定拒绝该任务吗？" data-ajax-method="Delete" data-ajax-mode="replace" data-ajax-update="#Main" href="@Url.Action("Delete", new { id = item.Id, type = "Accept", finish = Request["finish"], Accept = false, displaytype = Request["displaytype"], pageIndex = Request["pageIndex"] })"><i class="fa fa-check"></i>&nbsp;已接受</a>

                                <span>&nbsp;</span>
                                <a class="btn btn-small btn-primary" data-ajax="true" data-ajax-confirm="您确定已完成该任务吗？" data-ajax-method="Delete" data-ajax-mode="replace" data-ajax-update="#Main" href="@Url.Action("Delete", new { id = item.Id, type = "Finish", finish = true, displaytype = Request["displaytype"], pageIndex = Request["pageIndex"] })"><i class="fa fa-check"></i>&nbsp;完成</a>
                            }
                        }
                    }
                    else
                    {
                        <span>&nbsp;</span>
                        <a class="btn btn-small btn-success" data-ajax="true" data-ajax-method="Delete" data-ajax-mode="replace" data-ajax-update="#Main" href="@Url.Action("Delete", new { id = item.Id, type = "Accept", finish = Request["finish"], Accept = true, displaytype = Request["displaytype"], pageIndex = Request["pageIndex"] })"><i class="fa fa-check"></i>&nbsp;@lang.Accept</a>
                        <span>&nbsp;</span>
                        <a class="btn btn-small btn-danger" data-ajax="true" data-ajax-method="Delete" data-ajax-mode="replace" data-ajax-update="#Main" href="@Url.Action("Delete", new { id = item.Id, type = "Accept", finish = Request["finish"], Accept = false, displaytype = Request["displaytype"], pageIndex = Request["pageIndex"] })"><i class="fa fa-times"></i>&nbsp;拒绝</a>
                    }
                }
            </span>
            @Html.Partial("ProjectTaskItem", item)
        </blockquote>
    }
    @Html.Raw(Ajax.MikePager(Model))
</div>
